home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Random2.0 / Source / TestDieRoller.m < prev    next >
Text File  |  1995-06-12  |  959b  |  68 lines

  1. //
  2. // TestDieRoller
  3. //
  4.  
  5.  
  6. #import "DieRoller.h"
  7. #import "ElkinsEngine.h"
  8. #import <stdio.h>
  9. #import <stdlib.h>
  10.  
  11.  
  12. #define SAMPLES        100000
  13.  
  14.  
  15. //
  16. // test_dieroller()
  17. //
  18.  
  19. int test_dieroller(id roller)
  20. {
  21.     ulong    results[100];
  22.     int        i;
  23.     
  24.     //
  25.     // Test rollDie:
  26.     //
  27.     
  28.     printf("TestDieRoller: Rolling %d 20-sided dice.\n", SAMPLES);
  29.     for(i = 0; i < 20; i++)
  30.         results[i] = 0;
  31.     for(i = 0; i < SAMPLES; i++)
  32.     (results[[roller rollDie:20] - 1])++;
  33.     for(i = 0; i < 20; i++)
  34.         printf("%2d: %d (%f%%)\n", i + 1, results[i], (double)results[i] / (double)SAMPLES * 100);
  35.     
  36.     printf("\n\n");
  37.     
  38.     //
  39.     // Test roll:die:
  40.     //
  41.     
  42.     //
  43.     // Test rollBest:of:die:
  44.     //
  45.     
  46.     return 0;
  47. }
  48.  
  49.  
  50. //
  51. // main()
  52. //
  53.  
  54. int main(int argc, char *argv[])
  55. {
  56.     id        myRoller;
  57.     
  58.     myRoller = [[DieRoller alloc] initEngineClass:[ElkinsEngine class]];
  59.     
  60.     test_dieroller(myRoller);
  61.     
  62.     return 0;
  63. }
  64.  
  65.  
  66. //
  67. // End of file.
  68. //